package com.hdoit.kylin.logical.group.dao.impl;
import java.util.List;

import org.springframework.stereotype.Component;

import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.FinderExpressionFactory;
import com.hdoit.kylin.logical.group.dao.ILessonTrainDao;
import com.hdoit.kylin.logical.group.model.LessonTrain;
import com.hdoit.kylin.logical.user.model.Teacher;
import com.hdoit.kylin.logical.viewmodel.LessonTrainSearch;
/**
* @author luozhicheng
* @email
* @createtime 2017年07月26日 18:56:48
* @comment
*/
@Component
public class LessonTrainDaoImpl extends SuperDao<LessonTrain> implements ILessonTrainDao{
	@Override
	public int queryCount(LessonTrainSearch search) {
		IFinderExpression finderExpression = FinderExpressionFactory
				.createExpression();
		finderExpression.addBody("select count(id) from",LessonTrain.class)
					    .leftJoin(Teacher.class,"teacher")
					    .on("group_lessonTrain.dutyId", "teacher.employeeId");
		return queryCount(finderExpression, search);
	}
	
	@Override
	public List<LessonTrain> queryList(LessonTrainSearch search, PagerModel pagerModel){
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("lessonTrain.*","teacher.teacherName as teacherName")
						.from(LessonTrain.class,"lessonTrain")
						.leftJoin(Teacher.class, "teacher")
						.on("lessonTrain.dutyId", "teacher.employeeId");
		finderExpression.addOrderInfoList(getOrderInfoList());
		return queryList(finderExpression,search,pagerModel);
	}
}